Skip to content

[RF] Avoid expensive double loop in setData() for likelihooods#19529

Merged
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:evaluator_wrapper_optim
Aug 5, 2025
Merged

[RF] Avoid expensive double loop in setData() for likelihooods#19529
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:evaluator_wrapper_optim

Conversation

@guitargeek
Copy link
Contributor

About 2 years ago in 85c5cb4, I made the mistake of introducing a potentially expensive double loop when setting the data for a likelihood: the RooEvaluatorWapper iterates over all data variables to set, and for each of them it calls RooFit::Evaluator::setInput(), which has a loop over all nodes in the computation graph to identify for which one the data is set.

This caused a big performance hit when instantiating likelihoods with the new vectorizing CPU backend, manifesting in 10 minutes for createNLL for the big ATLAS Higgs combination benchmark instead of 1 min.

This commit fixes the problem by caching all nodes in the compute graph in a hash map for fast lookup.

About 2 years ago in 85c5cb4, I made the mistake of introducing a
potentially expensive double loop when setting the data for a
likelihood: the `RooEvaluatorWapper` iterates over all data variables to
set, and for each of them it calls `RooFit::Evaluator::setInput()`,
which has a loop over all nodes in the computation graph to identify for
which one the data is set.

This caused a big performance hit when instantiating likelihoods with
the new vectorizing CPU backend, manifesting in 10 minutes for
`createNLL` for the big ATLAS Higgs combination benchmark instead of
1 min.

This commit fixes the problem by caching all nodes in the compute graph
in a hash map for fast lookup.
@github-actions
Copy link

github-actions bot commented Aug 5, 2025

Test Results

    21 files      21 suites   3d 10h 33m 17s ⏱️
 3 224 tests  3 224 ✅ 0 💤 0 ❌
65 959 runs  65 959 ✅ 0 💤 0 ❌

Results for commit c1bea85.

♻️ This comment has been updated with latest results.

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you Jonas for fixing this!

@guitargeek guitargeek merged commit 01d6bda into root-project:master Aug 5, 2025
72 of 74 checks passed
@guitargeek guitargeek deleted the evaluator_wrapper_optim branch August 5, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants